package com.sims.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.sims.bean.AttendanceRecord;
import com.sims.bean.Student;
import com.sims.beanEnhanced.StudentAttendanceRecord;
import com.sims.dao.IAttendanceRecordDAO;
import com.sims.util.Constant;
import com.sims.util.HttpSessionUtil;

public class AttendanceRecordService {
	
	@Autowired
	IAttendanceRecordDAO attendanceRecordDAO;
	
	/** Add A Student's absence record
	 * @param attendanceRecord
	 * @return
	 */
	public Map<String, String> addAttendanceRecord(AttendanceRecord attendanceRecord) {
		Map<String, String> result = new HashMap<String, String>();
		
		attendanceRecordDAO.attachDirty(attendanceRecord);
		result.put(Constant.SUCCESS, null);
		
		return result;
	}
	
	/** List A Student's Attendance Record
	 * @param student Not necessary, if current user is a student, no need student.sid. Otherwise need.
	 * @param attendanceRecordList
	 * @return Map<String, String>
	 */
	public Map<String, String> findAttendanceRecord(Student student, List<StudentAttendanceRecord> attendanceRecordList) {
		
		Map<String, String> result = new HashMap<String, String>();
		
		List<StudentAttendanceRecord> temp = attendanceRecordDAO.findStudentAttendanceRecordBySid(student.getSid());
		
		for (StudentAttendanceRecord attendanceRecord : temp) {
			attendanceRecordList.add(attendanceRecord);
		}
		
		result.put(Constant.SUCCESS, null);
		
		return result;
	}
}
